#include<iostream>
using namespace std;
char s[105][205];
int arr[105][205];
int n, m;
void fun()
{
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i][j] == '*') {
				arr[i][j + 1]++;
				arr[i][j - 1]++;
				arr[i - 1][j]++;
				arr[i - 1][j + 1]++;
				arr[i - 1][j - 1]++;
				arr[i + 1][j]++;
				arr[i + 1][j + 1]++;
				arr[i + 1][j - 1]++;
			}
		}
	}
}
int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> s[i][j];
		}
	}
	fun();
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i][j] == '*') {
				cout << "*";
			}
			else {
				cout << arr[i][j];
			}
		}
		cout << endl;
	}
	return 0;
}